<?php
use App\PersonPublish;
use Pub\cache\Cache;
defined('IN_IA') or exit('Access Denied');
global $_GPC,$_W;

if($_W['container'] != 'wechat' || $_W['os'] != 'mobile'){
    message('本系统仅支持在手机端微信打开','','info');
    exit;
}

checkauth();
require MODULE_ROOT.'/vendor/autoload.php';

$_type = $_GPC["type"];
$_result = array("status"=>"error","msg"=>"未识别二维码");
switch ($_type){
    case 'publish-person':   //可发红包人员添加
        $PersonPublish = new PersonPublish();
        $_result = $PersonPublish->add($_W["member"]["uid"]);
        break;
    case 'bind-admin':   //绑定管理员
        $_cache_sign = Cache::get(Cache::BIND_ADMIN_SIGN,array('uniacid'=>$_GPC["uniacid"]));
        if($_cache_sign && $_cache_sign == $_GPC["sign"]){
            Cache::remove(Cache::BIND_ADMIN_SIGN,array("uniacid"=>$_GPC["uniacid"]));
            Cache::set(Cache::TEMP_BIND_ADMIN_UID,$_W["member"]["uid"],array("uniacid"=>$_GPC["uniacid"]));
            $_result = array("status"=>"success","msg"=>"申请管理员成功，后台确认设置");
        }else{
            $_result = array("status"=>"error","msg"=>"二维码失效");
        }
        break;
}


include $this->template('scan');